﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Lamex.SIESystemManager.Calculate
{
    public class C_D42
    {
        public double GetD42(string W1, string W2, string Codes)
        {
            double TD42 = 0, Tw1 = 0, Tw2 = 0;
            Tw1 = double.Parse(string.IsNullOrEmpty(W1) ? "0" : W1);
            Tw2 = double.Parse(string.IsNullOrEmpty(W2) ? "0" : W2);
            //20190829 robin要求更改
            // string[] strCode = { "4401", "4404", "4409", "4412", "4418", "4420", "4431" };
            string[] strCode = { "D001", "D004", "D009", "D012", "D018", "D020", "D031", "D035", "D037", "D040", "D046", "D058", "D064", "D066", "D067" };
            if (strCode.Contains(Codes) && NumMAX(Tw1, Tw2) < 1000)
            {
                TD42 = (0.000058 * Tw1 * Tw2 + 4) * 2 + 24;
            }
            else if (strCode.Contains(Codes))
            {
                TD42 = (0.000058 * Tw1 * Tw2 + 4) * 2 + 24;
            }
            else
            {
                TD42 = 24;
            }

            return TD42;
        }
        private static double NumMAX(double Tw1, double Tw2)
        {
            if (Tw1 > Tw2)
            {
                return Tw1;
            }
            return Tw2;
        }
    }
}
